Fix ESLint plugin dependencies#368
Conversation
|
I accidentally clicked "Ready for review" while this PR was originally opened as a draft for maintainer feedback. I’ll leave it ready for now to avoid extra status noise, but the intended scope is still the same: this only fixes ESLint dependency/config resolution and does not address the existing lint violations. Feedback on whether this is the right direction is very welcome. |
|
@mariozenmedina Thanks for your work on this, I think focusing on getting the dependencies working is a sensible approach. As part of this it would be good to add a basic {
"globals": {
"jQuery": "readonly",
"wp": "readonly",
"FormData": "readonly",
"fetch": "readonly",
"ajaxurl": "readonly"
},
"settings": {
"import/core-modules": [
"@wordpress/api-fetch",
"@wordpress/block-editor",
"@wordpress/blocks",
"@wordpress/components",
"@wordpress/compose",
"@wordpress/core-data",
"@wordpress/data",
"@wordpress/date",
"@wordpress/edit-post",
"@wordpress/element",
"@wordpress/i18n",
"@wordpress/plugins",
"@wordpress/primitives",
"@wordpress/rich-text"
]
},
"extends": "plugin:@wordpress/eslint-plugin/recommended"
} |
|
Thanks. I've just added a root I've also updated |
Description of the Change
Draft for maintainer feedback: this PR focuses only on fixing ESLint dependency resolution so
wp-scripts lint-jscan load the project configs. It does not attempt to fix the existing lint violations that are surfaced afterward.The root
.eslintrcextendsplugin:@wordpress/eslint-plugin/recommended, but@wordpress/eslint-pluginwas only available as a nested dependency of@wordpress/scripts. Because ESLint resolves plugins from the project config location, it could not find the WordPress ESLint plugin from the project root.There is a similar issue for Cypress linting:
tests/cypress/.eslintrcextendsplugin:cypress/recommended, buteslint-plugin-cypresswas not declared as a project dependency.After making those plugins resolvable, ESLint also reaches the WordPress config's TypeScript import resolver setup. The newer resolver interface is not compatible with this project's current ESLint 8 /
eslint-plugin-importstack, causing:Resolve error: typescript with invalid interface loaded as resolverThis PR pins
eslint-import-resolver-typescriptto3.5.5, which is compatible with the current ESLint stack.After this change,
wp-scripts lint-jsloads the configs/plugins successfully and reaches the existing lint violations, mostly CRLF/Prettier-related formatting errors, which are outside the scope of this PR.Closes #352
How to test the Change
Using Node 20, matching
.nvmrc:npm ci.npx wp-scripts lint-js.Expected result:
@wordpress/eslint-pluginoreslint-plugin-cypress.Resolve error: typescript with invalid interface loaded as resolver.I also validated config loading with:
./node_modules/.bin/eslint --print-config assets/js/blocks.js./node_modules/.bin/eslint --print-config tests/cypress/support/index.jsChangelog Entry
Credits
Props @mariozenmedina
Checklist:
Documentation and new tests were not added because this is a development dependency/configuration fix. Existing linting still reports pre-existing formatting issues after the dependency resolution problem is fixed.